<template>
	<view class="frame">
		<view class="frame_top">
			<text>智慧公寓云平台服务系统</text>
			<view>维护员端</view>
		</view>
		<view style="width: 100%;display: flex;flex-wrap: wrap;margin-bottom: 150rpx;">
		<view class="frame1" style="background-color: #2979ff;" @click="click">注册</view>
		<view class="frame1" style="background-color: #f29100;" @click="click1">报修</view>
		<view class="frame1" style="background-color: #18b566;" @click="click2">水电</view>
		<view class="frame1" style="background-color: #6633FF;" @click="click3">巡检</view>
		</view>
		<view class="frame_top1">
			<u--image src="../../static/image/logo.png" width="100" height="100"></u--image>
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userInfo: "",
			};
		},
		onShow() {
			var that = this
			that.checkUser()
		},
		methods: {
			// 注册点击事件
			click() {
				var that = this
				that.checkUser()
				if (that.userInfo == null) {
					uni.showToast({
						icon: 'none',
						duration: 3000,
						title: "您还未登录"
					});
				} else {
					if (that.userInfo.tel == '') {
						uni.navigateTo({
							url: "../apply/apply?path=Mstaff"
						})
					} else {
						uni.showToast({
							icon: 'none',
							duration: 3000,
							title: "您已经注册过了"
						});
					}
				}
			},
			// 点击报修事件
			click1() {
				// console.log('我是报修管理')
				var that = this
				that.checkUser()
				if (that.userInfo == null) {
					uni.showToast({
						icon: 'none',
						duration: 3000,
						title: "您还未登录"
					});
				} else {
					if (that.userInfo.tel == '') {
						uni.showToast({
							icon: 'none',
							duration: 3000,
							title: "您还没注册"
						});
					} else if (that.userInfo.status == 0) {
						uni.showToast({
							icon: 'none',
					 	duration: 3000,
							title: "审核还未通过"
						});
					} else {

						uni.navigateTo({
					 	url: "./repair_list"
						})
					}
				}
			},
			// 点击水电事件
			click2() {
				// console.log('我是水电管理')
				var that = this
				that.checkUser()
				if (that.userInfo == null) {
					uni.showToast({
						icon: 'none',
						duration: 3000,
						title: "您还未登录"
					});
				} else {
					if (that.userInfo.tel == '') {
						uni.showToast({
							icon: 'none',
							duration: 3000,
							title: "您还没注册"
						});
					} else if (that.userInfo.status == 0) {
						uni.showToast({
							icon: 'none',
							duration: 3000,
							title: "审核还未通过"
						});
					} else {
						uni.navigateTo({
							url: "./water_ele"
						})
					}
				}
			},
			// 点击巡检
			click3() {
				// console.log('我是水电管理')
				var that = this
				that.checkUser()
				if (that.userInfo == null) {
					uni.showToast({
						icon: 'none',
						duration: 3000,
						title: "您还未登录"
					});
				} else {
					if (that.userInfo.tel == '') {
						uni.showToast({
							icon: 'none',
							duration: 3000,
							title: "您还没注册"
						});
					} else if (that.userInfo.status == 0) {
						uni.showToast({
							icon: 'none',
							duration: 3000,
							title: "审核还未通过"
						});
					} else {
						uni.navigateTo({
							url: "./polling_record"
						})
					}
				}
			},
			// 检查用户信息
			checkUser() {
				var that = this
				var userInfo = that.userInfo;
				// if(userInfo == ''){
				if (localStorage.getItem('userInfo')) {
					that.userInfo = JSON.parse(localStorage.getItem('userInfo'))
				} else {
					that.userInfo = null
					// uni.showToast({
					//     icon: 'none',   
					//     duration: 3000,
					//     title: "当前用户未登录"
					// });
					return;
				}
				// }

			},
		}
	}
</script>

<style lang="scss">
	.frame {
		display: flex;
		flex-wrap: wrap;
		background-color: white;
		// padding-top: 50px;
		height: 100vh;
		align-items: center;
	}

	.frame1 {
		// margin-bottom: 150px;
		margin-left: 2.5%;
		margin-top: 20rpx;
		width: 30%;
		height: 250rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 30rpx;
		color: white;
		font-size: 50rpx;
	}

	.frame_top {
		display: flex;
		position: fixed;
		flex-direction: column;
		top: 20rpx;
		width: 100vw;
		// text-align: center
		align-items: center;
		justify-content: center;
		font-size: 34rpx;
	}
	.frame_top1 {
		display: flex;
		position: fixed;
		flex-direction: column;
		bottom: 20rpx;
		width: 100vw;
		// text-align: center
		align-items: center;
		justify-content: center;
	}
</style>
